<?php
/* Home controller 
** thaodx@gmail.com
*/
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {
	// Layout used in this controller
    public $layout_view = 'layout/tattoos';

	public function index($page = 0, $lastId = 0)
	{

		$page = intval($page);
		$lastId = intval($lastId);

		$this->load->model('Post_model', 'postModel');
		$this->load->model('Cate_model', 'cateModel');
		$this->load->helper(array('datetime', 'permalink', 'social', 'image'));
		//NEW HOME
		$latestPost = $this->postModel->getLatestPost($page, HOME_NEW_LIMIT, $lastId);		       	
		//NEW HOME
		$mostPost = $this->postModel->getLatestPost($page, 13, $lastId);		       	
		//NEW HOT
		$hotPost = $this->postModel->getLatestPost($page, 3, $lastId);		       	
		//NEW HOT
		$cateInfo = $this->cateModel->getCateBySlug("hot-tattoos");
		$cateInfo = $cateInfo[0];
		if(empty($cateInfo)) header('location:'.BASE_URL);				
		$latestPostHot = $this->postModel->getPostByCate($cateInfo['category_id'], $page, CATE_HOT_LIMIT, $lastId);					
		$this->layout->title(SITE_TITLE . TITLE_SEPARATOR . 'Latest Tattoos'); // Set page title
		$this->layout->meta('<meta http-equiv="REFRESH" content="1800" />');

       	$data = array('hotPost'=>$hotPost,'mostPost'=>$mostPost,'latestPost'=>$latestPost,'latestPostHot' => $latestPostHot, 'cid' => $cateInfo['category_id'], 'fullCateCode' => 'category/' . $cateInfo['category_slug']);
       	// sidebar
       	//$sidebar = $this->layout->renderBlock('block/cate-side-bar');
       	//$this->layout->sidebar($sidebar);		
       	$this->layout->view('home_index', $data);// Render view and layout
	}
}
